Ensure every mocks payload folder has a 404 case - #340
Conversation
DGFIP::TVA::ValidateResponse and both CNOUS student-scholarship interactors already return a NotFoundError on an empty provider response, but the rswag request specs never documented a 404 case for these endpoints (the v4/v5 CNOUS specs were cloned from v3 with only the 200 path). Add the missing response blocks and regenerate the OpenAPI docs so the public spec matches actual behavior.
21 of 107 endpoint folders had no not-found test case. Add a 404.yaml to each, matching the (now complete, see previous commit) OpenAPI documentation for that operation, and regenerate the per-folder READMEs.
The skill only checked for missing payload folders, not for folders that exist but lack a 404 case, and it told agents to skip 404 whenever the OpenAPI spec didn't document it. Since NotFoundError is a universal error every SIADE interactor can emit, an undocumented 404 is almost always a spec gap, not a real absence of the case. Add a step to check 404 coverage on existing folders, and replace the skip-if-undocumented rule with instructions to check the interactor code and, if it does call resource_not_found!, fix the rswag spec and regenerate the OpenAPI docs before writing the mock.
skelz0r
left a comment
There was a problem hiding this comment.
Vis-à-vis du premier commit, je pense que ça serait plus intelligent de juste augmenter les swaggers post générations, y'a pas de plu-value à les générer via rswag.
C'est du détail, mais ça mérite d'être mentionné pour qu'à l'avenir on simplifie ce qu'on peut simplifier.
|
Ça se débat mais je trouve que c'est mieux comme ça en vrai, les tests RSwag servent de référence, augmenter le fichier openAPI ailleurs c'est + complexe pour un gain minimal |
|
On le fait déjà https://github.com/datagouv/apistration/blob/develop/siade/bin/augment_openapi_files.rb, et en vrai je trouve que c'est plus logique de mettre tous les trucs génériques (400, 401, 403, 404, 502) dans un post processing plutôt que de faire tourner la stack. Si il y a de la logique métier c'est cohérent de faire tourner la stack pour la capturer, là y'a aucun intérêt. D'ailleurs limite on pourrait retirer 400/401/403 (voir 404/502) de notre swagger vu que c'est normalisé |
|
Pour moi les 404 y'a une logique métier non? 🤔 |
Dans certains cas (genre CNAF/MSA où t'as des sous-codes), mais majoritairement c'est "On n'a rien trouvé", et ça peut s'auto-complète avec un post processing. C'est du cas par cas. Mon point ici est que dans le RSwag on complète les cas métiers qu'on veut mettre en avant pour que ça transparaisse dans le swagger, et le post processing s'occupe des boring stuffs. |
Summary
mocks/payloads/endpoint folders had no not-found test case. Investigated each: for 14 of them the OpenAPI spec already documented a 404 (payload written straight from the spec's example); for the remaining 7 (api_entreprise_v3_dgfip_tvaand all 6cnous_etudiant_boursierv4/v5 variants) the spec simply never documented one, even though the underlying siade interactors already produce aNotFoundErrorin that case.response '404'rswag blocks to the siade request specs (mirroring sibling/prior-version endpoints), added a WebMock "not found" stub for DGFIP TVA, and regeneratedcommons/swagger/*.yamlso the public OpenAPI docs now match actual behavior.404.yamlto all 21 folders and regenerated their READMEs.siade-sync-openapi-payloadsskill so future syncs always check 404 coverage (not just missing folders) and know to fix an undocumented-but-real 404 at the siade/rswag level instead of skipping it.